<?
class AnonsBO extends BusinessObject{
  var $SHOW_IN_ALL = 0;
  var $FOR_MAIN = 1;
  /* private function using in constructors*/ 
  function setAttributes(){
    $this->fields   = array(
			'id'		=>	'anons_ID',
			'title'		=>	'anons_Title',
			'descr'		=>	'anons_Descr',
			'date'		=>	'anons_Date',
			'side'		=>	'anons_SiteSide',
			'visible'	=>	'anons_Visible',
			'article_id'=>	'anons_ArticleID',
			'caption_article_id'=>'anons_CaptionArticleID',
			'position'	=>	'anons_Position',
			'ttl'		=>	'anons_TTL');

    $a = new ArticleBO();
    $this->relations = array("{$a->tableName}" =>"{$a->tableName}.{$a->fields[id]} = {$this->tableName}.{$this->fields[article_id]}");

    BusinessObject::setAttributes();
  }  
  /* constructor */
  function AnonsBO(){
    /** super(tableName) */
    BusinessObject::BusinessObject("anons");
    $this->setAttributes();
  }

  function get_ttl_values_as_html($selected_ttl){
    $options = "";
    $ttls = array(0 =>'відображати завжди',1 =>'одну добу',7 =>'одну неділю' ,30 =>'один місяць(30ть днів)');
    foreach($ttls as $key => $val){
      $options.= "<option value='$key' ".(($selected_ttl==$key)?"selected":"").">$val</option>";
    }
    return($options);
  } 

  function is_art_exist($id){
  	$a = new ArticleBO();
	$a->id = $id;
	OB_START();
	$a->Load(0,1);
	OB_END_CLEAN();
	if( $a->Next()){ return true; }
	 else { return false; }
  
  }

}
?>
